// 1. 建routes数组
// 2. 导出实例
// 3. 去main.js中挂载到vue实例中
import Vue from 'vue';
import VueRouter from 'vue-router';
import Homepage from '../pages/homepage';
import Play from '../pages/play';
import PlayList from '../pages/play-list';
import Recommend from '../pages/homepage/pages/recommend';
import HotSong from '../pages/homepage/pages/hot-song';
import Search from '../pages/homepage/pages/search';
import SearchSuggest from '../pages/homepage/pages/search/pages/search-suggest';
import SearchList from '../pages/homepage/pages/search/pages/search-list';
import SearchHot from '../pages/homepage/pages/search/pages/search-hot';

Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    component: Homepage,
    redirect: '/recommend',
    children: [
      {
        path: 'recommend',
        component: Recommend,
      },
      {
        path: 'hot-song',
        component: HotSong,
      },
      {
        path: 'search',
        component: Search,
        redirect: '/search/search-hot',
        children: [
          {
            path: 'search-suggest',
            component: SearchSuggest,
            name: 'search-suggest',
          },
          {
            path: 'search-list',
            component: SearchList,
            name: 'search-list',
          },
          {
            path: 'search-hot',
            component: SearchHot,
          },
        ],
      },
    ],
  },
  {
    path: '/play',
    component: Play,
  },
  {
    path: '/play-list/:id',
    name: 'play-list',
    component: PlayList,
  },
];

export default new VueRouter({ routes });
